var mysql = require('mysql');
var db = {};
var connection = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: 'root',
    database: 'myapp',
    port: 3306
});
connection.connect(function (err) {
    if (err) {
        console.log(err.message)
    }
});
db.query = function sqlback(sqllan, fn) {
    var sql = sqllan;
    if (!sql) return;
    connection.query(sql, function (err, rows, fields) {
        if (err) {
            console.log(err);
            return;
        }
        console.log(fields);
        fn(rows);
    });
}
module.exports = db;